package com.example.javapoint.block;

class Animal {
    private int age;
    private String name;

    Animal() {
        System.out.println("Animal is available");
    }
}

class Dog extends Animal {
    Dog() {
        super();
        System.out.println("dog is available!");
    }

    {
        System.out.println("this is block code!");
    }

    public void bark() {
        System.out.println("this dog is barking!");
    }
}

/**
 * 代码块
 * 子类构造函数中如果继承了父类，会调用父类的构造函数super()
 * 将代码块中的代码复制到super() 之后, 再编译子类中的代码
 */
public class CodeBlock {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.bark();
    }
}
